class QueryEntity {
    constructor({
                    frameName = '',
                    frameNameAction = 0,
                    houseId = '',
                } = {}) {
        this.frameName = frameName;
        this.frameNameAction = frameNameAction;
        this.houseId = houseId;
    }
}

new BasicTableVue({
    data: function () {
        return {
            actions:fieldFormatter.form.action,
            api: baseFrameInfoApi,
            columns: [
                TableColumn.generate({
                    type: 'selection',
                    width: 30,
                    align: 'center',
                }),
                TableColumn.generate({
                    prop: 'id',
                    title: 'ID',
                    align: 'center',
                }),
                TableColumn.generate({
                    prop: 'frameName',
                    title: '机架名称',
                    align: 'center',
                }),
                TableColumn.generate({
                    prop: 'useType',
                    title: '使用类型',
                    formatter: this.useTypeFormat,
                    align: 'center',
                }),
                TableColumn.generate({
                    prop: 'distribution',
                    title: '分配类型',
                    formatter: this.distributionFormat,
                    align: 'center',
                }),
                TableColumn.generate({
                    prop: 'occupancy',
                    title: '占用状态',
                    formatter: this.occupancyFormat,
                }),
                TableColumn.generate({
                    prop: 'occupationNum',
                    title: '占用数',
                    align: 'center',
                }),
                TableColumn.generate({
                    prop: 'houseName',
                    title: '所在机房',
                    align: 'center',
                    sortable: false,
                }),
                TableColumn.generate({
                    prop: 'operating',
                    title: '操作',
                    sortable: false,
                    align: 'center',
                    customComponent: 'true',
                }),
            ],
            houses: [],
        }
    },
    methods: {
        createForm() {
            return new QueryEntity({
                houseId: forward.getData().id,
            });
        },
        forwardUpdate(data) {
            forward('/basic-data/modify/admin_frameinfo_modify', data);
        },
        async initHousesData() {
            this.houses = await baseHouseInfoApi.selectList();
        },
        init() {
            this.initHousesData();
        },
        useTypeFormat(rowData, column, value, index) {
            var result = '';
            switch (value) {
                case 1:
                    result = '自用';
                    break;
                case 2:
                    result = '自建';
                    break;
            }
            return result;
        },
        distributionFormat(rowData, column, value, index) {
            var result = '';
            switch (value) {
                case 1:
                    result = '未分配';
                    break;
                case 2:
                    result = '已分配';
                    break;
            }
            return result;
        },
        occupancyFormat(rowData, column, value, index) {
            var result = '';
            switch (value) {
                case 1:
                    result = '未占用';
                    break;
                case 2:
                    result = '已占用';
                    break;
            }
            return result;
        },
        async downloadTemplate() {
            await baseFrameInfoApi.downloadTemplate('机架信息管理导入模板.xlsx');
        },
    },
    watch: {},
})


